<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>登录</title>
</head>
<body>
    <form action="#">
        <h1>登录</h1>
        <div>
            <label for="phone">手机号</label>
            <input id="phone" type="text">
        </div>
        <div>
            <label for="pwd">密码</label>
            <input id="pwd" type="password">
        </div>
        <input type="submit">
    </form>
    <script>
        let phone = document.getElementById("phone");
        let pwd = document.getElementById("pwd");
        document.forms[0].onsubmit = function(e){
            e.preventDefault();
            let users = JSON.parse(sessionStorage.getItem("users"));
            for(let i = 0;i < users.length;i++){
                if(users[i].phone == phone.value && 
                    users[i].pwd == pwd.value){
                        alert("登录成功");
                        return;
                }
            }
            alert("登录失败");
        }
    </script>
</body>
</html>